package com.xindaoapp.happypet.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeFormat {
	private static long aDay = 86400*1000;
	private static long aYear = 86400 * 365*1000;
	private static Date parse;

	private static TimeFormat timeFormat = new TimeFormat();

	public static TimeFormat getInstance() {
		return timeFormat;
	}

	private TimeFormat() {
		super();
	}

	@SuppressWarnings("unused")
	public static String format(String addtime) {
		SimpleDateFormat format6 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			parse = format6.parse(addtime);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		long add = parse.getTime();
		long date = System.currentTimeMillis();
		long gap = date - add;
		if (gap < aDay) {
			SimpleDateFormat format = new SimpleDateFormat("HH:mm");
			String str1 = format.format(add);
			return str1;

		}
		if (gap > aDay && gap < aYear) {
			SimpleDateFormat format2 = new SimpleDateFormat("MM-dd");
			String str2 = format2.format(add);
			return str2;
		}
		if (gap > aYear) {
			SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd");
			String str3 = format3.format(add);
			return str3;
		}
		return addtime;
	}
}
